/*
 * > /*
 >  * INSANE - Interactive Structural Analysis Environment
 >  *
 >  * Copyright (C) 2003-2004
 >  * Universidade Federal de Minas Gerais
 >  * Escola de Engenharia
 >  * Departamento de Engenharia de Estruturas
 >  *
 >  * Author's email :     insane@dees.ufmg.br
 >  * Author's Website :   http://www.dees.ufmg.br/insane
 >  *
 >  * This program is free software; you can redistribute it and/or
 >  * modify it under the terms of the GNU General Public License
 >  * as published by the Free Software Foundation; either version 2
 >  * of the License, or any later version.
 >  *
 >  * This program is distributed in the hope that it will be useful,
 >  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 >  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 >  * GNU General Public License for more details.
 >  *
 >  * You should have received a copy of the GNU General Public License
 >  * along with this program; if not, write to the Free Software
 >  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
 > 1307, USA.
 *
 */


package br.ufmg.dees.insane.xyplot.xyplot_model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;


/**
 * @author  Penna, Samuel  TODO To change the template for this generated type comment go to  Window - Preferences - Java - Code Style - Code Templates
 */
public class XYPlot implements Serializable{
	
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;
	
	/** The title of this graphic. */	
	protected String title;
	
	/** An ArrayList containing all Sequences of this graphic. */
	protected List<ISequence> sequencesList = new ArrayList<ISequence>();
	
	/** An ArrayList containing all Axis of this graphic. */
	protected List<Axis> axisList = new ArrayList<Axis>();
	
//	******************************************************************************
	
	/** Constructs a XYZPlot, sets its title to oneTitle.*/
	public XYPlot(String oneTitle, List<Axis> axs, List<ISequence> seq){
		
		title = oneTitle;
		axisList = axs;
		sequencesList = seq;
		
	}		
	
	public XYPlot(){}
	
//	******************************************************************************
	
	/**
	 * Returns the title of this graphic.
	 * @return  The tilte of this graphic.
	 * @uml.property  name="title"
	 */
	public String getTitle(){
		return title;
	}
	
	/**
	 * Sets the title of this graphic.
	 * @param newTitle  The title of this graphic.
	 * @uml.property  name="title"
	 */
	public void setTitle(String newTitle){
		title = newTitle;
	}	
	
//	******************************************************************************
	
	/**
	 * Returns the sequencesList of this graphic.
	 * @return  The sequencesList of this graphic.
	 * @uml.property  name="sequencesList"
	 */
	public List<ISequence> getSequencesList(){
		return sequencesList;
	}
	
	/**
	 * Sets the sequencesList of this graphic.
	 * @param newSequencesList  The sequncesList of this graphic.
	 * @uml.property  name="sequencesList"
	 */
	public void setSequencesList(List<ISequence> newSequencesList){
		sequencesList = newSequencesList;
	}
	
//	******************************************************************************
	
	/** Add a sequnce in this graphic.
	 *  @param newSequence The Sequence which will be add in this graphic.
	 */
	public void add(ISequence newSequence){	
		sequencesList.add(newSequence);
	}
	
//	******************************************************************************
	
	/** Remove a sequence of this graphic.
	 *  @param aSequence The Sequence which will be removed.
	 */	
	public void remove(ISequence aSequence){
		ISequence sqc;
		ListIterator seq = sequencesList.listIterator();
		while (seq.hasNext()) {
			sqc = (ISequence)seq.next();
			if (sqc.equals(aSequence)){
				seq.remove();
			}
		}
	}
	
//	******************************************************************************
	
	/** Remove a sequence at the specified position in this graphic.
	 *  @param index The position of the sequence which will be removed.
	 */	
	public void remove(int index) {
		sequencesList.remove(index);
	}
	
//	******************************************************************************
	
	/** Returns the sequence at the specified position in this sequencesList.
	 *  @return The sequence specified.
	 */
	public ISequence getSequence(int index) {
		return (ISequence)sequencesList.get(index);
	}
	
	/** Sets the sequence at the specified position in this sequencesList.
	 *  @param index The position of the sequence which will be set.
	 *  @param seq The sequence of this Sequences list.
	 */
	public void setSequence(int index, ISequence seq) {
		sequencesList.set(index, seq);
	}
	
//	******************************************************************************
	
	/** Returns the position of a specified sequence in this sequencesList.
	 *  @param aSeq The sequence of this sequencesList.
	 */
	public int indexOf(ISequence aSeq) {
		int index = -1;
		ISequence sqc;
		ListIterator seq = sequencesList.listIterator();
		while (seq.hasNext()) {
			sqc = (ISequence)seq.next();
			if (sqc.equals(aSeq)){
				index = sequencesList.indexOf(sqc);
			}
		}
		return index;
	}
	
//	*****************************************************************************
	
	/** Remove all sequencess from this list.*/	
	public void clearSequences() {
		sequencesList.clear();
	}
	
//	******************************************************************************
	
	/**
	 * Returns the axisList of this graphic.
	 * @return  The axisList of this graphic.
	 * @uml.property  name="axisList"
	 */
	public List<Axis> getAxisList(){
		return axisList;
	}
	
	/**
	 * Sets the AxisList of this graphic.
	 * @param newAxisList  The axisList of this graphic.
	 * @uml.property  name="axisList"
	 */
	public void setAxisList(List<Axis> newAxisList){
		axisList = newAxisList;
	}
	
//	******************************************************************************
	
	/** Add a axis in this graphic.
	 *  @param newAxis The axis which will be add in this graphic.
	 */
	public void add(Axis newAxis){	
		axisList.add(newAxis);
	}
	
//	******************************************************************************
	
	/** Remove a axis of this graphic.
	 *  @param aAxis The Axis which will be removed.
	 */	
	public void remove(Axis aAxis){
		Axis xyz;
		ListIterator axs = axisList.listIterator();
		while (axs.hasNext()) {
			xyz = (Axis)axs.next();
			if (xyz.equals(aAxis)){
				axs.remove();
			}
		}
	}
	
//	******************************************************************************
	
	/** Returns the axis at the specified position in this axisList.
	 *  @return The axis specified.
	 */
	public Axis getAxis(int index) {
		return (Axis)axisList.get(index);
	}
	
	/** Sets the axis at the specified position in this axisList.
	 *  @param index The position of the axis which will be set.
	 *  @param axs The axis of this axis list.
	 */
	public void setAxis(int index, Axis axs) {
		axisList.set(index, axs);
	}
	
//	*****************************************************************************
	
	/** Remove all axis from this list.*/	
	public void clearAxis() {
		axisList.clear();
	}
	
//	******************************************************************************
	
}